##Take data table and process box plot arrays for different thresholds

import csv
import os

##Fill in file path correctly here
os.chdir("C:\\Users\\njimenez\\Desktop")

threshold_dict = {}
threshold_list = []
master_table = []

master_filename = "Area Ratio Results.csv"
with open (master_filename,newline='') as RatioFile:
    table = csv.reader(RatioFile)
    for row in table:
        threshold = row[1]
        threshold_dict[threshold] = "found"
        master_table.append(row)
        
for key in threshold_dict:
    threshold_list.append(key)
    unique_thresholds = len("threshold_list")

for threshold in threshold_list:
    threshold_string = str(threshold)
    output_filename = "Threshold_"+threshold_string+".csv"
    
    with open (output_filename, 'w', newline = '') as csvfile:
        Output_File = csv.writer(csvfile)       
        
        for row in master_table:
            if row [1] == threshold_string:
                Output_File.writerow(row)
        

    
